package com.cy.sys.log.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cy.sys.log.page.vo.JSONResult;
import com.cy.sys.log.service.SysMenusService;
import com.cy.sys.pojo.SysMenus;

//@Controller
@RestController//等效于@Controller+@ResponseBody当前类所有都是转成JSON串
@RequestMapping("/menu/")
public class sysMenuscontroller {
	@Autowired
	private SysMenusService sysmenus;
	
	@RequestMapping("doFindObjects")
	//@ResponseBody//还可写在类上
	public JSONResult doGetMenusList() {
		return new JSONResult(sysmenus.getMenusfindObject());
	}
	
	@RequestMapping("doDeleteObject")
	//@ResponseBody//还可写在类上
	public JSONResult doDeleteObject(Integer id) {
		//System.out.println(id+"==============");
		sysmenus.deleteObject(id);
		return new JSONResult("deletge ok");
	}
	
	//树结构查询
	@RequestMapping("doFindZtreeMenuNodes")
	public JSONResult doFindZtreeMenuNodes() {
		return new JSONResult(sysmenus.findzTree());	
	}
	//新增操作
	@RequestMapping("doSaveObject")
	public JSONResult doSaveObject(SysMenus sysmenu) {
		sysmenus.doinsertObject(sysmenu);
		return new JSONResult("inser ok");
	}
	
	//修改操作
		@RequestMapping("doUpdateObject")
		public JSONResult doUpateObject(SysMenus sysmenu) {
			sysmenus.doupdateObject(sysmenu);
			return new JSONResult("update ok");
		}
}
